package com.dalin.platform.log.service.imple;

import java.util.ArrayList;
import java.util.List;

import com.dalin.common.pager.PageInfo;
import com.dalin.common.utils.DateUtils;
import com.dalin.framework.service.imple.FrameServiceImple;
import com.dalin.platform.loa.LoaConst;
import com.dalin.platform.log.condition.LogOperateCondition;
import com.dalin.platform.log.model.LogOperateEntity;
import com.dalin.platform.log.service.LogService;
import com.dalin.platform.log.vo.LogOperateDetailVoIn;
import com.dalin.platform.log.vo.LogOperateVoIn;
import com.dalin.platform.log.vo.LogOperateVoOut;

/*****************************************************************************
 * @content: 类信息                                                   *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-06-23                                                     *
 * @modDate: 2010-06-23                                                     *
 * @version: 1.00                                                           *
 ****************************************************************************/
public class LogServiceImple extends FrameServiceImple
		implements LogService {

    public PageInfo queryLogOperates(LogOperateCondition cond)throws Exception {
        PageInfo pageInfo = queryPageInfoByCond(cond);
        List<LogOperateEntity> entyList = pageInfo.getDataList();
        List<LogOperateVoOut> voList = new ArrayList<LogOperateVoOut>();
        LogOperateVoOut vo = null;
        for (LogOperateEntity enty : entyList) {
            vo = new LogOperateVoOut();
	        vo.setLogOperateId(enty.getLogOperateId()); // 
	        vo.setOperateUserName(LoaConst.getUserNameById(enty.getOperateUserId()));
	        vo.setOperateIp(enty.getOperateIp());
	        vo.setCreateTime(DateUtils.getYmdhisStr(enty.getCreateTime()));
	        voList.add(vo);
        }
        pageInfo.setDataList(voList);
        return pageInfo;
    }

    public void addLogOperate(LogOperateVoIn vo, List<LogOperateDetailVoIn> detailList)throws Exception {
        LogOperateEntity enty = new LogOperateEntity();
        enty.setOperateUserId(vo.getOperateUserId()); // 
        enty.setOperateIp(vo.getOperateIp());
        enty.setCreateTime(DateUtils.getCurrentDate());
        getDao().createObj(enty);
    }

    public void delLogOperatesByIds(Long[] idArray)throws Exception {
        getDao().deleteObjs(LogOperateEntity.class, idArray);
    }
}
